﻿using Microsoft.AspNetCore.Mvc;
using AhCha.Fortunate.Common.Const;
using AhCha.Fortunate.IService.MSSQL;
using Microsoft.AspNetCore.Authorization;
using AhCha.Fortunate.ModelsDto.MSSQL.LoginDto;
using AhCha.Fortunate.ModelsDto;
using AhCha.Fortunate.Api.AppCode;



namespace AhCha.Fortunate.Api.Controllers.MSSQL
{
    /// <summary>
    /// 系统登录模块
    /// </summary>
    [ApiController]
    [AllowAnonymous]
    [ApiExplorerSettings(GroupName = SwaggerGroupName.BusinessModules)]
    public class LoginController(ILoginService iLoginService) : BaseApiController
    {
        private readonly ILoginService _iLoginService = iLoginService;

        /// <summary>
        /// 测试自定义输出
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        [DiyResult] // 自定义输出标识
        public async Task<ResponseOutput> GetData()
        {
            //CaptchaOutput? entity = await _iLoginService.GetData();
            return Success(Yitter.IdGenerator.YitIdHelper.NextId(), "测试自定义输出");
        }

        /// <summary>
        /// 获取登录密钥（自定义输出标识）
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        [DiyResult] // 自定义输出标识
        public ResponseOutput GetKey1() => Success(GetDynamicAesKey);

        /// <summary>
        /// 获取登录密钥
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public string GetKey2() => GetDynamicAesKey;

        /// <summary>
        /// 获取验证码
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public async Task<CaptchaOutput> VerificationCode() => await _iLoginService.GetVerificationCode();

        /// <summary>
        /// 账户登录
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public async Task<string> LoginAccount(LoginInput input) => await _iLoginService.LoginAccount(input);

        /// <summary>
        /// 发送短信验证码
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<string> SendSms(LoginMobileInput input) => await _iLoginService.GetSendSms(input);

        /// <summary>
        /// 手机号码登录
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<string> LoginPhone(LoginMobileInput input) => await _iLoginService.LoginPhone(input);

    }
}
